package com.sun.mybatisplus.bean.entity;


import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

@TableName("tbl_form_model")
public class TblFormModel extends BaseEntity implements Serializable {
//    public static final String APPLY = 1;
//    public static final int REIMBURSEMENT = 2;
//    public static final int OTHERS = 3;

    @TableId
    private Long id;
    private String name;
    //访问地址
    private String code;
    @ApiModelProperty("类型 1 申请单 2 报销单 3 其他")
    private String type;
    @ApiModelProperty("表单")
    private String formData;
    @ApiModelProperty("表单列表字段")
    private String formTableColumns;
    @ApiModelProperty("关联模型表")
    private String tables;

    private Byte deleted;
    private String memo;
    @ApiModelProperty("表单配置")
    private String config;
    @ApiModelProperty("事项")
    private String buttons;

    @ApiModelProperty("事项")
    private String item;
    @ApiModelProperty("申请单ID, 类型为报销单时，此字段有值。类型为报销单且此字段值为0时，则为直接报销单")
    private Long applyFormId;
    @ApiModelProperty("报销次数 0：一次，1：多次")
    private Integer times;
    @ApiModelProperty("排序")
    private Integer sort;

    @ApiModelProperty("单据状态")
    private Byte formStatus;
    @ApiModelProperty("基础配置状态")
    private Byte baseConfigStatus;
    @ApiModelProperty("打印配置状态")
    private Byte printConfigStatus;
    @ApiModelProperty("是否关联事前申请单")
    private Byte relevanceBefore;
    @ApiModelProperty("流水规则code")
    private String flowRuleCode;

    @ApiModelProperty("类型编码")
    private String typeCode;

    private String options;
    @ApiModelProperty("预算方案")
    private String assignBudgetPlan;
    @ApiModelProperty("预算")
    private String assignBudget;
    @ApiModelProperty("图标")
    private String icon;
    @ApiModelProperty("单据分类")
    private String category;
    @ApiModelProperty("收款方式")
    private String paymentWay;

    private String relevanceData;

    public String getRelevanceData() {
        return relevanceData;
    }

    public void setRelevanceData(String relevanceData) {
        this.relevanceData = relevanceData;
    }
/*@TableField(exist = false)
    private List<ButtonDTO> buttonDTOS;
    @TableField(exist = false)
    private List<FormDataDTO> mainTableFormData;
    @TableField(exist = false)
    private List<FormDataDTO> subTableFormData;
    @TableField(exist = false)
    private List<FormDataDTO> formDataList;
    @TableField(exist = false)
    private List<ModuleTableRelation> tableRelations;
    @TableField(exist = false)
    private ModuleTableRelation mainTable;*/

    public String getAssignBudgetPlan() {
        return assignBudgetPlan;
    }

    public void setAssignBudgetPlan(String assignBudgetPlan) {
        this.assignBudgetPlan = assignBudgetPlan;
    }

    public String getAssignBudget() {
        return assignBudget;
    }

    public void setAssignBudget(String assignBudget) {
        this.assignBudget = assignBudget;
    }

    public String getOptions() {
        return options;
    }

    public void setOptions(String options) {
        this.options = options;
    }

    public Byte getFormStatus() {
        return formStatus;
    }

    public void setFormStatus(Byte formStatus) {
        this.formStatus = formStatus;
    }

    public Byte getBaseConfigStatus() {
        return baseConfigStatus;
    }

    public void setBaseConfigStatus(Byte baseConfigStatus) {
        this.baseConfigStatus = baseConfigStatus;
    }

    public Byte getPrintConfigStatus() {
        return printConfigStatus;
    }

    public void setPrintConfigStatus(Byte printConfigStatus) {
        this.printConfigStatus = printConfigStatus;
    }

    public Byte getRelevanceBefore() {
        return relevanceBefore;
    }

    public void setRelevanceBefore(Byte relevanceBefore) {
        this.relevanceBefore = relevanceBefore;
    }

    /*public List<FormDataDTO> getSubTableFormData() {
        return subTableFormData;
    }

    private void setSubTableFormData() {
        this.subTableFormData = formDataList.stream().filter(o -> o.getType().equals(FormDataTypeEnum.TABLE.name()) && StringUtils.isNotBlank(o.getSubTableName())).collect(Collectors.toList());
    }

    public ModuleTable getModuleTable(){
        ModuleTable moduleTable = JSONUtil.toBean(this.getFormTableColumns(), ModuleTable.class);
        return moduleTable;
    }

    public List<ModuleTableRelation> getTableRelations(){
        return tableRelations;
    }
*/
    public Long getApplyFormId() {
        return applyFormId;
    }

    public void setApplyFormId(Long applyFormId) {
        this.applyFormId = applyFormId;
    }

   /* public List<FormDataDTO> getFormDataList(){
        return this.formDataList;
    }

    public ModuleTableRelation getMainTable(){
        return mainTable;
    }

    private void setMainTable(){
        ModuleTableRelation mainTable = tableRelations.stream().filter(o -> o.getType() == ModuleTableRelation.MAIN_TABLE).findFirst().get();
        this.mainTable = mainTable;
    }


    public List<FormDataDTO> getMainTableFormData(){
       return this.mainTableFormData;
    }*/

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getFormData() {
        return formData;
    }

   /* public void setFormData(String formData) {
        this.formData = formData;
        setFormDataList();
        setMainTableFormData();
        setSubTableFormData();
    }

    private void setMainTableFormData(){
        this.mainTableFormData = this.formDataList.stream().filter(o -> !o.getType().equals(FormDataTypeEnum.TABLE.name())).collect(Collectors.toList());
    }
    private void setTableRelations(){
        TypeReference<List<ModuleTableRelation>> reference = new TypeReference<List<ModuleTableRelation>>(){};
        this.tableRelations = JSONUtil.toBean(this.tables, reference, false);
        setMainTable();
    }

    private void setFormDataList(){
        TypeReference<List<FormDataDTO>> typeReference = new TypeReference<List<FormDataDTO>>(){};
        List<FormDataDTO> formDataDTOList = JSONUtil.toBean(this.formData, typeReference.getType(), false);
        this.formDataList = formDataDTOList;
//        List<FormDataDTO> formDataDTOList = JSON.parseArray(this.formData,FormDataDTO.class);
//        this.formDataList = JSON.parseArray(this.formData,FormDataDTO.class);
    }*/
    public String getFormTableColumns() {
        return formTableColumns;
    }

    public void setFormTableColumns(String formTableColumns) {
        this.formTableColumns = formTableColumns;
    }

    public String getTables() {
        return tables;
    }

   /* public void setTables(String tables) {
        this.tables = tables;
        setTableRelations();
    }*/

    public Byte getDeleted() {
        return deleted;
    }

    public void setDeleted(Byte deleted) {
        this.deleted = deleted;
    }

    public String getMemo() {
        return memo;
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    public String getButtons() {
        return buttons;
    }

    /*public void setButtons(String buttons) {
        this.buttons = buttons;
        if(Strings.isNotBlank(buttons)){
            this.buttonDTOS = JSONUtil.parseArray(buttons).toList(ButtonDTO.class);
        }
    }*/

    public String getConfig() {
        return config;
    }

    public void setConfig(String config) {
        this.config = config;
    }

    public String getItem() {
        return item;
    }

    public void setItem(String item) {
        this.item = item;
    }

    /*public List<ButtonDTO> getButtonDTOS() {
        return buttonDTOS;
    }

    public void setButtonDTOS(List<ButtonDTO> buttonDTOS) {
        this.buttonDTOS = buttonDTOS;
    }*/

    public Integer getTimes() {
        return times;
    }

    public void setTimes(Integer times) {
        this.times = times;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public String getTypeCode() {
        return typeCode;
    }

    public void setTypeCode(String typeCode) {
        this.typeCode = typeCode;
    }

    public String getFlowRuleCode() {
        return flowRuleCode;
    }

    public void setFlowRuleCode(String flowRuleCode) {
        this.flowRuleCode = flowRuleCode;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getPaymentWay() {
        return paymentWay;
    }

    public void setPaymentWay(String paymentWay) {
        this.paymentWay = paymentWay;
    }

    /*public static void main(String args[]){
        TypeReference<List<FormDataDTO>> typeReference = new TypeReference<List<FormDataDTO>>(){};
        System.out.println(typeReference.getType());
    }*/
}
